#ifndef LESSON_AUDITOR_H
#define LESSON_AUDITOR_H

#include <QtGui/QMainWindow>
#include <QSQLDatabase>
#include "ui_lesson_auditor.h"
#include "helper.h"
#include "policy.h"
#include "serveradapter.h"
#include "serverargs.h"


class lesson_auditor : public QMainWindow
{
	Q_OBJECT

public:
	lesson_auditor(QWidget *parent = 0, Qt::WFlags flags = 0);
	~lesson_auditor();
	bool isAccepted();

private:
	Ui::lesson_auditorClass ui;
	ServerAdapter serverAdapter;
	QSqlDatabase db;
	ServerArgs * args;
	/*!
	* lesson id for current lesson
	* variant and mod id for current student
	*/
	int lessonid, variantid, modid, modattemptid, studentid, lessontypeid;

	/*!
	* policy object for the lesson
	*/
	Policy lesson_policy;

	/*!
	* Last used directory to student's files
	*/
	QString stdDir;



	/*!
	* set data for given student and lesson type in controls
	*/
	void setStudentLessontypeData();
	/*!
	* set student variant fields and returns variantid or -1
	*/
	void setVariant(int studentid);
	/*!
	* set student modification fields and returns modid or -1
	*/
	void setMod(int studentid, int variantid);
	/*!
	* Enable/disable quiz/srs/mod groups depending of what is allowed and what is done
	*/
	void ajustAvailability(int studentid,int lessontypeid,int lessonid);
	/*!
	* Adjust contents of complexity combo box depending on what complexities available for choosen variant
	*/
	void adjustComplexity();
	/*!
	* Returns id for choosen complexity
	*/
	int lesson_auditor::getComplexityId();
	

private slots:
	//overall
	void startLesson();
	void finishLesson();
	void studentSelected(const QModelIndex & index);
	void lessonTypeChanged(int indx);
	//quiz
	void quizRemember();
	//srs variant
	void srsSelectVariant();
	void srsShowDescription();
	//srs testing
	void srsSelectFile();
	void srsDoTesting();
	//mod variant
	void modStartAttempt();
	void modShowDescription();
	void modCancel();
	//mod testing
	void modSelectFile();
	void modDoTesting();
	//reports
	void lessonSaveReport();
	void lessonShowReport();
	void lessonImportReport();
	void unlessonGrades();
	void gradeShowReport();
	//edit dialogs
	void editVarModDescriptions();
};

#endif // LESSON_AUDITOR_H
